const jwt = require('jsonwebtoken');
const { PRIVATE_KEY } = require('../app/config')
class AuthContraller {
    async login(ctx, next) {
        const { name, id } = ctx.user
        console.log(ctx.user);
        const token = jwt.sign({ name, id }, PRIVATE_KEY, {
            expiresIn: 60 * 60 * 24, // 有效时间
            algorithm: 'RS256' //加密算法
        })
        ctx.body = {
            message: '登录成功',
            token, id, name
        }
    }
    async success(ctx, next) {
        ctx.body = "授权成功！"
    }
}
module.exports = new AuthContraller()